package hku.cs.lunuo.rank;

public class Tarantula extends Voter {

	@Override
	public Label vote(VotedUnit u, VotedGlobal g) {		
		int falseCases = u.tf.getFlsTimes();
		int trueCases = u.tf.getTruTimes();
		float perFalse;
		if (falseCases == 0)
			perFalse = 0;
		else
			perFalse = falseCases/ (float) g.getTotalFls();
		float perTrue;
		if (trueCases == 0)
			perTrue = 0;
		else
			perTrue = trueCases / (float) g.getTotalTru();

		float susc;
		if (perFalse + perTrue == 0)
			susc = 0;
		else
			susc = perFalse / (perFalse + perTrue);
		
		float conf = perFalse > perTrue ? perFalse : perTrue;
		return new DefaultLabel(susc, conf);
	}

}
